<template>
    <div class="topbar">
        <div>
        欢迎来到小伟的博客页面
        </div>
    <div>   
        <span style="margin-right: 100px;">
            <a-button type="text" v-if="topurl() === 'backend'" 
            @click="router.push({name:'EditBlogs'})"> 
                前台
            </a-button>
            <a-button type="text" v-if="topurl() === 'frontend'" > 后台</a-button>
        </span>
        <a-button type="text" v-if="!state.is_login" @click="c">
            登录
        </a-button>
        <a-button type="text" v-if="state.is_login" @click="c">
            退出
        <icon-export />
        </a-button>
        
    </div>   
    </div>
     
</template>

<script setup>
import { useRouter } from 'vue-router';
import {state} from '../stores/app'

const router = useRouter()
const c = () => {router.push({name:'Login'})}

const topurl = ()=> {
//    console.log(router.currentRoute.value.fullPath)
   if (router.currentRoute.value.fullPath.startsWith('/frontend')) {
    return 'frontend'
   }else {
    return 'backend'
   }
}
topurl()
</script>

<style lang="css" scoped>
.topbar {
    display: flex;
    align-content: center;
    justify-content: space-between;
    margin: 20px 20px;
}
</style>